package Demo7;

class Mythread extends Thread {
    public void run() {
        while(true) {
            System.out.println("新线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Mythread();

        //直接调用run方法
        //t.run();

        //通过start方法
        t.start();

        while(true) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
